package me.caofeng.dao;

import com.sun.org.apache.xpath.internal.operations.Or;
import me.caofeng.enums.OrderStatus;
import me.caofeng.enums.Role;
import me.caofeng.pojo.*;
import org.apache.ibatis.annotations.Param;
import org.omg.PortableServer.LIFESPAN_POLICY_ID;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.PathVariable;

import javax.print.DocFlavor;
import java.util.Date;
import java.util.List;

/**
 * Copyright © 2017曹峰. All rights reserved.
 *
 * @Prject: mall
 * @Package: me.caofeng.dao
 * @Description:
 * @Author: 曹峰 blog.caofeng.me
 * @Date: 2017-06-29 15:20
 * @Version: V1.0
 */
@Repository
public interface OrderMapper {
    Order getOrder(@Param("userId") String userId , @Param("orderId") String OrderId);

    List<OrderItem> getOrderItems(@Param("userId") String userId , @Param("orderId") String OrderId);

    List<Order> getOrders(@Param("userId") String userId, @Param("status") OrderStatus status, @Param("role") Role role,
                          @Param("page") Page page);

    int addOrder(Order order);

    int addOrderItem(@Param("orderItems") List<OrderItem> orderItems);

    /**
     * @Author:曹峰 blog.caofeng.me
     * @Date: 2017/6/30 17:31
     * @Description: 保存支付信息
    */
    int addAlipayInfo(AlipayInfo alipayInfo);

    Integer isOrderExists(@Param("userId") String userId,@Param("orderId") String orderId);

    /**
     * @Author:曹峰 blog.caofeng.me
     * @Date: 2017/7/1 17:00
     * @Description: 验证支付宝回调信息是否正确
    */
    String verifyAlipayCallback(@Param("orderId") String orderId ,@Param("price") int price);

    /**
     * @Author:曹峰 blog.caofeng.me
     * @Date: 2017/7/1 17:15
     * @Description: 更新支付宝支付信息
    */
    int updateAlipayInfo(AlipayInfo alipayInfo);

    int updateOrder(Order order);

    int deleteAlipayInfo(@Param("orderId") String orderId,@Param("userId") String userId);

    int updatePayTime(@Param("id") int id , @Param("time") Date time);

    int cancelOrder(@Param("userId") String userId,@Param("orderId") String orderId);

    int deleteOrder(@Param("userId") String userId,@Param("orderId")String orderId);

    int updatePostStatus(@Param("orderId") String orderId, @Param("status") OrderStatus status);

    int addPostInfo(PostInfo postInfo);

    Order getOrderUserAndAddress(String orderId);

    int signOrder(@Param("orderId") String orderId, @Param("userId") String userId,@Param("status") OrderStatus status);

    int updatePostInfo(PostInfo postInfo);
}
